import 'package:flutter/material.dart';

class ListenExample extends StatefulWidget {
  ListenExample({Key? key}) : super(key: key);

  @override
  _ListenExampleState createState() => _ListenExampleState();
}

class _ListenExampleState extends State<ListenExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('手势监听'),
      ),
      body: Center(
        child: Stack(
          children: [
            Listener(
              onPointerDown: (event) {
                print("onPointerDown----$event");
              },
              onPointerMove: (event) {
                print("onPointerMove----$event");
              },
              onPointerUp: (event) {
                print("onPointerUp----$event");
              },
              // onPointerSignal: (event) {
              //   print("onPointerSignal----$event");
              // },
              // onPointerCancel: (event) {
              //   print("onPointerCancel----$event");
              // },
              // onPointerEnter: (event) {
              //   print("onPointerEnter----$event");
              // },
              // onPointerExit: (event) {
              //   print("onPointerExit----$event");
              // },
              // onPointerHover: (event) {
              //   print("onPointerHover----$event");
              // },
              child: Container(
                color: Colors.pink,
                width: 200,
                height: 200,
                child: Text(
                  "Jimi",
                  style: TextStyle(color: Colors.white, fontSize: 30),
                ),
              ),
            ),
            Positioned(
              child: Listener(
                onPointerDown: (event) {
                  print("red---- $event");
                },
                child: Container(
                  width: 100,
                  height: 100,
                  color: Colors.orange,
                  child: Text("Jimi"),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
